package work.igames.vertxcreate.controller;

import io.netty.handler.codec.http.HttpHeaderNames;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import work.igames.vertxcreate.enitity.UserSkill;
import work.igames.vertxcreate.handler.UserSkillHandler;
import work.igames.vertxcreate.service.UserSkillAsyncService;

/**
 * @ClassName UserSkilController
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2020/10/30 上午10:59
 * @Version V1.0
 * @Since JDK 11
 */
@Component
public class UserSkillVerticle extends AbstractVerticle {

    private Router router;

    @Autowired
    private UserSkillHandler userSkillHandler;

    @Override
    public void start(Promise<Void> startPromise) throws Exception {
        router = Router.router(vertx);
        router.get("/skill").handler(routingContext -> userSkillHandler.dispatch("findAll", routingContext));
        router.get("/skill/:name").handler(routingContext -> userSkillHandler.dispatch("findByName", routingContext));
        vertx.createHttpServer().requestHandler(router).listen(9979);
    }
}
